<template>
  <div class="edit-post-transfer">
    <el-table border :data="postTransfers.list" ref="multipleTable" style="width: 100%">
      <el-table-column type="selection" width="50" align="center" />
<!--      <el-table-column prop="id" label="ID" align="center" width="150"/>-->
      <el-table-column prop="name" label="员工姓名" align="center" width="150"/>
      <el-table-column prop="stationNow" label="目前所在岗位" align="center" width="100" />
      <el-table-column prop="stationToTransfer" label="申请调动岗位" align="center" width="100"/>
      <el-table-column prop="transferType" label="调动类型" align="center" width="100"/>
      <el-table-column prop="transferReason" label="调动原因" align="center" width="100"/>
      <el-table-column prop="applyDate" label="申请日期" align="center" width="100"/>
      <el-table-column prop="approveState" label="审批状态" align="center" width="100"/>
      <el-table-column prop="approveResult" label="审批结果" align="center" width="100"/>
      <el-table-column prop="dealDate" label="处理日期" align="center" width="100"/>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              @click="agreeApprove(scope.row)">同意</el-button>
          <el-button
              size="mini"
              type="danger"
              @click="rejectApprove(scope.row)">驳回</el-button>
        </template>
      </el-table-column>
    </el-table>


<!--    <div class="menu">-->
<!--      <el-pagination-->
<!--          background-->
<!--          layout="prev, pager, next"-->
<!--          :pager-count="5"-->
<!--          :total="postTransfers.total"-->
<!--          :hide-on-single-page="false"-->
<!--          @current-change="handleCurrentChange"-->
<!--          :page-size="8"-->
<!--      />-->
<!--      &lt;!&ndash;      <el-button type="danger" size="small" @click="deleteUser">删除</el-button>&ndash;&gt;-->
<!--    </div>-->
<!--    <el-dialog :visible.sync="dialogVisible">-->
<!--      <el-form label-width="80px" v-model="postTransfer">-->
<!--        <el-input type="hidden" v-model="postTransfer.id" />-->
<!--        <el-form-item label="审批意见" prop="approveComment">-->
<!--          <el-input type="textarea" v-model="postTransfer.transferReason" placeholder="审批意见" maxlength="300" show-word-limit/>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
<!--      <div class="dialog-footer" slot="footer">-->
<!--        <el-button @click="dialogVisible = false"> 取消 </el-button>-->
<!--        <el-button @click="updatePostTransfer" type="primary"> 确认 </el-button>-->
<!--      </div>-->
<!--    </el-dialog>-->
  </div>
</template>

<script>
import {getPostTransfers, agreeApprove, rejectApprove} from "../../utils/api";

export default {
  name: "EditPostTransfer",
  data() {
    return {
      postTransfers: {},
      postTransfer: {},
      dialogVisible: false,
      stations: [{
        value: '初级开发',
        label: '初级开发'
      }, {
        value: '高级开发',
        label: '高级开发'
      }, {
        value: '产品',
        label: '产品'
      }, {
        value: '运营',
        label: '运营'
      }],
      transferTypeEnum: [{
        value: '升职',
        label: '升职'
      }, {
        value: '贬谪',
        label: '贬谪'
      }]
    };
  },
  created() {
    this.getPostTransfers();
    // this.getStations();
  },
  methods: {
    getPostTransfers(pageNumber) {
      getPostTransfers({ pageNumber }).then((response) => {
        if (response && response.status === "success") {
          this.postTransfers = response.data;
        }
      });
    },
    handleEdit(row) {
      this.postTransfer = row;
      this.dialogVisible = true;
    },
    agreeApprove(row) {
      agreeApprove(row).then((response) => {
        if (response && response.status === "success") {
          this.$message.success(response.message);
          this.dialogVisible = false;
          this.getPostTransfers();
        }
      });
    },
    rejectApprove(row) {
      rejectApprove(row).then((response) => {
        if (response && response.status === "success") {
          this.$message.success(response.message);
          this.dialogVisible = false;
          this.getPostTransfers();
        }
      });
    },
    handleCurrentChange(pageNumber) {
      this.getPostTransfers(pageNumber);
    },
  },
};
</script>

<style scoped>
.el-pagination {
  margin-right: auto;
}

.menu {
  margin-top: 20px;
  display: flex;
}
</style>